﻿// JavaScript Document
/**
* @fileOverview  flw注册页面使用
* @description 
* ......
* 20130610 mericmo 创建
* @author mericmo   
* @version 1.0.0
* @date 
* @bug 无
* @warning 无
**/
//===============全局变量定义区域=======================
/*命名空间说明：
* 命名空间: FLW.regi
*/
$namespace("FLW.regi");
FLW.regi.globe = {
	careerInfoUrl:"./account.html",
	iMailRegi:"http://localhost:8080/web/user/register?",//mail registor interface param loginName=hsia@163.com&password=123456
	iMobileRegi:"http://localhost:8080/web/user/register?"
};
var other = FLW.regi;
//初始化
FLW.regi.init = function(d){
	//初始数据
	$extend(FLW.regi.globe,d);
	//运行环境检查
	FLW.regi.check();
	//页面渲染
	FLW.regi.render();
};
//运行环境检查
FLW.regi.check = function(){
};
//页面渲染
FLW.regi.render =function(){
	var that = FLW.regi.globe;
	//tab切换
	$slider({
		auto:false,
		effect:"none",
		initIndex:0,
		className:"cur",
		titleId:"hd02_tabs",    //tab标题的id
		titleTag:"li",    //tab的元素类型
		contentId:"tab_content",    //内容的id    
		contentTag:"div"    //内容元素类型
	});
	
	$addEvent($id("mobile_num"),"blur",function(){//手机号输入框
		var mobileNum = this.value.trim();
		if(!mobileNum || !$isMobile(mobileNum)){
			$display("mobile_num_tips2");
			$display("mobile_num_tips1","none");
			return false;
		}else{
			$display("mobile_num_tips1,mobile_num_tips2","none");
			return true;
		}
	});
	$addEvent($id("mobile_num"),"keyup",function(){//手机号输入框
		var mobileNum = this.value.trim();
		if(mobileNum && $isMobile(mobileNum)){
				$display("mobile_num_tips1,mobile_num_tips1","none");
			return true;
		}
		return false;
	});
	$addEvent($id("mobile_pwd"),"keyup",function(){//手机注册密码输入框
		var passwd = this.value.trim();
		if(!passwd){
			$display("mobile_pwd_tips1","none");
			$display("mobile_pwd_tips2");
			return false;
		}else if($strLenGB(passwd)>=6){
			$display("mobile_pwd_tips1,mobile_pwd_tips2","none");
		}
		return true;
	});
	$addEvent($id("mobile_pwd"),"blur",function(){//手机注册密码输入框
		var passwd = this.value.trim();
		if($strLenGB(passwd)<6){
			$display("mobile_pwd_tips1");
			$display("mobile_pwd_tips2","none");
			return true;
		}
	});
	$addEvent($id("btn_register1"),"click",function(){//mobile register
		if(!other.checkMobileRegi()){
			return false;
		}
		var mailAddr = $id("mobile_num").value.trim();
		var passwd = $id("mobile_pwd").value.trim();
		window["mobile_regi_callback"] = function(data){
			alert("请求已成功提交并回包。")
		};
		$loadScript(other.globe.iMobileRegi+$makeUrl({loginName:mailAddr,password:passwd,callback:"mobile_regi_callback"}));
	});
	$addEvent($id("mail_addr"),"blur",function(){//邮箱地址输入框
		var mailAddr = this.value.trim();
		if(!mailAddr || !$isMail(mailAddr)){
			$display("mail_addr_tips");
			return false;
		}else{
			$display("mail_addr_tips","none");
			return true;
		}
	});
	$addEvent($id("mail_addr"),"keyup",function(){//邮箱地址输入框
		var mailAddr = this.value.trim();
		if(mailAddr && $isMail(mailAddr)){
				$display("mail_addr_tips","none");
			return true;
		}
		return false;
	});
	$addEvent($id("mail_pwd"),"keyup",function(){//邮箱密码输入框
		var passwd = this.value.trim();
		if(!passwd){
			$display("mail_pwd_tips1","none");
			$display("mail_pwd_tips2");
			return false;
		}else if($strLenGB(passwd)>=6){
			$display("mail_pwd_tips1,mail_pwd_tips2","none");
		}
		return true;
	});
	$addEvent($id("mail_pwd"),"blur",function(){//邮箱密码输入框
		var passwd = this.value.trim();
		if($strLenGB(passwd)<6){
			$display("mail_pwd_tips1");
			$display("mail_pwd_tips2","none");
			return true;
		}
	});
	$addEvent($id("mail_regi_reg"),"blur",function(){//邮箱注册验证码
		var verifyKey = this.value.trim();
		
		if(!verifyKey){
			$display("mail_regi_reg_tips");
			return false;
		}else{
			$display("mail_regi_reg_tips","none");
			return true;
		}
	});
	$addEvent($id("btn_register2"),"click",function(){//mail regi
		if(!other.checkMailRegi()){
			return false;
		}
		var mailAddr = $id("mail_addr").value.trim();
		var passwd = $id("mail_pwd").value.trim();
		window["mail_regi_callback"] = function(data){
			alert("请求已成功提交并回包。")
		};
		$loadScript(other.globe.iMailRegi+$makeUrl({loginName:mailAddr,password:passwd,callback:"mail_regi_callback"}));
	});
};
//邮箱注册，验证
FLW.regi.checkMailRegi = function(){
	var mailAddr = $id("mail_addr").value.trim();
	var passwd = $id("mail_pwd").value.trim();
	if(!mailAddr || !$isMail(mailAddr)){
		return false;
	}
	if(!passwd ||$strLenGB(passwd)<6){
		return false;
	}
	var verifyKey = $id("mail_regi_reg").value.trim();
	if(!verifyKey){
		$display("mail_regi_reg_tips");
		return false;
	}
	return true;
};
//手机注册，验证
FLW.regi.checkMobileRegi = function(){
	var mobileNum = $id("mobile_num").value.trim();
	var passwd = $id("mobile_pwd").value.trim();
	if(!mobileNum || !$isMobile(mobileNum)){
		return false;
	}
	if(!passwd ||$strLenGB(passwd)<6){
		return false;
	}
	//手机号验证码，待完善
	return true;
};
